package com.ghost.manager
{
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.media.Sound;
	import flash.system.ApplicationDomain;
	import flash.utils.getDefinitionByName;
	
	public class Source_manager
	{
		private static var inst:Source_manager;
		public static function getInstance():Source_manager
		{
			if(inst == null)
			{
				inst = new Source_manager();
			}
			return inst;
		}
		public function Source_manager()
		{
			
		}
		//获得游戏中的mc
		public function getSource(str:String):MovieClip
		{
			if( !ApplicationDomain.currentDomain.hasDefinition(str) ) return null;
			var cl:Class = getDefinitionByName(str) as Class;
			if(cl == null) return null;
			var mc:MovieClip = new cl() as MovieClip;
			return mc;
		}
		//获得游戏中的mc的类
		public function getSource_c(str:String):Class
		{
			if( !ApplicationDomain.currentDomain.hasDefinition(str) ) return null;
			var cl:Class = getDefinitionByName(str) as Class;
			return cl;
		}
		//获得游戏中的BitmapData
		public function getBitmapData(str:String):BitmapData
		{
			if( !ApplicationDomain.currentDomain.hasDefinition(str) ) return null;
			var cl:Class = getDefinitionByName(str) as Class;
			if(cl == null) return null;
			var bd:BitmapData = new cl() as BitmapData;
			return bd ;
		}
		//获得游戏中的class
		public function getBitmapData_class(str:String):Class
		{
			if( !ApplicationDomain.currentDomain.hasDefinition(str) ) return null;
			var cl:Class = getDefinitionByName(str) as Class;
			if(cl == null) return null;
			return cl ;
		}
		//获得游戏中的Sound
		public function getSound(str:String):Sound
		{
			if( !ApplicationDomain.currentDomain.hasDefinition(str) ) return null;
			var cl:Class = getDefinitionByName(str) as Class;
			if(cl == null) return null;
			var mc:Sound = new cl() as Sound;
			return mc ;
		}
	}
}